package com.example.textview;

import android.content.Context;
import android.content.SharedPreferences;

import java.util.HashMap;
import java.util.Map;

public class Utils {
    public boolean saveData(Context c, String s1, String s2){
        SharedPreferences sp = c.getSharedPreferences("qq", c.MODE_PRIVATE);
        SharedPreferences.Editor e = sp.edit();
        e.putString("username", s1);
        e.putString("password", s2);
        e.commit();
        return true;
    }

    public Map<String, String> getData(Context c){
        SharedPreferences sp = c.getSharedPreferences("qq", c.MODE_PRIVATE);
        String s1 = sp.getString("username", null);
        String s2 = sp.getString("password", null);
        if (s1=="" || s2=="")
            return null;
        Map<String, String> userMap = new HashMap<>();
        userMap.put("username", s1);
        userMap.put("password", s2);
        return userMap;
    }
}
